package com.example.service.impl;

import com.example.entity.pojo.Dept;
import com.example.mapper.DeptMapper;
import com.example.service.DeptService;
import com.example.service.EmpService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Primary
public class DeptServiceImpl2 implements DeptService {
    @Autowired
    private DeptMapper deptMapper;
    @Autowired
    private EmpService empService;
    @Override
    public List<Dept> selectAll() {
        return deptMapper.selectAll();
    }

    // 删除部门的同时，删除部门下的员工
    @Transactional
    @Override
    public int deleteById(Integer id) {
        int i= deptMapper.deleteById(id);
        int a=1/0;
        int i2=empService.deleteByDeptId(id);
        return i;
    }
}
